import {constants} from "./constants.js";
import {Character} from "./characters/Character.js";
import {heroImg} from "./resources.js";
import {elements} from "./elements.js";
import {Hero} from "./characters/Hero.js";

class MainController {
    #timer
    /**
     * @type {Hero}
     */
    #hero

    run = ()=>{
        clearInterval(this.#timer);
        this.#timer = setInterval(()=>{
            this.clear()
            this.#hero.move()
        }, constants.FRAME_TIME * 1000)
    }

    init = ()=>{
        this.#hero = new Hero()
    }

    getHero =  ()=>this.#hero

    clear = ()=>{
        elements.context.clearRect(0,0,elements.canvas.height,elements.canvas.width);
    }
}

export const mainController = new MainController();